﻿/* AgileFx Version 1.0
 * An open-source framework for rapid development of applications and services using Microsoft.net
 * Developed by: AgileHead
 * Website: www.agilefx.org
 * This component is licensed under the terms of the Apache 2.0 License.
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects.DataClasses;

namespace AgileFx.EF
{
    public class RuleException : Exception
    {
        public RuleException()
            : base()
        {
        }

        public RuleException(string errorCode)
            : base()
        {
            this.errors.Add(new Message(errorCode));
        }

        public RuleException(List<Message> errors) : base()
        {
            this.errors.AddRange(errors);
        }

        private List<Message> errors = new List<Message>();
        public List<Message> Errors { get { return errors; } }
    }

    public class RuleException<T> : RuleException where T : EntityObject, new()
    {
        public T Item { get; set; }
        public RuleException(T t)
            : base()
        {
            this.Item = t;
        }
    }
}
